package Day17;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {



    }

    public static void main0 (String[] args) {

        Scanner scanner = new Scanner(System.in);
        String string = scanner.nextLine();
        string.toUpperCase();
        String s = scanner.nextLine();
        s.toUpperCase();
        Character c = s.charAt(0);

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < string.length(); i++) {
            if (map.containsKey(string.charAt(i))) {
                map.put(string.charAt(i), 1 + map.getOrDefault(string.charAt(i), 0));
            } else {
                map.put(string.charAt(i), 1);
            }
        }
        System.out.println(map.getOrDefault(c, 0));
    }

}
